package com.example.parallaxlistview;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ImageView;

public class MainActivity extends Activity {

	private ParallaxScrollListView mListView;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		
		mListView = (ParallaxScrollListView)findViewById(R.id.listview);
		View head = View.inflate(this, R.layout.head, null);
		ImageView iv = (ImageView)head.findViewById(R.id.iamge);
		mListView.setParallaxImageView(iv);
		mListView.addHeaderView(head);
		ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
				android.R.layout.simple_list_item_1, new String[]{
				"1 2","3 4","5 6","7 8","9 10"
		});
		mListView.setAdapter(adapter);
	}

	//当activity把布局全部显示完回调
	@Override
	public void onWindowFocusChanged(boolean hasFocus) {
		super.onWindowFocusChanged(hasFocus);
		if( hasFocus){
			//设置mListView里面的ImageView的高度
			mListView.setViewBounds(2);
		}
	}
	
}
